#include <iostream>
#include <queue>

using namespace std;

const int N = 1e6 + 10;

queue<int> q;
bool st[N];

int n, m, k;
int res;

int main()
{
	cin >> n >> m >> k;
	
	while (m -- )
	{
		int v;
		cin >> v;
		
		st[v] = true;
		q.push(v);
	}
	
	while (q.size())
	{
		auto a = q.front(); q.pop();
		
		if (st[(a + k) % n]) continue;
		
		st[(a + k) % n] = true;
		q.push((a + k) % n); 
	}
	
	for (int i = 0; i < n; i ++ ) 
		if (!st[i]) 
			res ++ ;
			
	cout << res << endl;
	
	return 0;
}
